-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added fallback getting displayInfo when displayInfo is null #3416
Conversation
Thank you.
Do you know why? Are there another I would prefer that over parsing |
No, It doesn't fixed yet. It can cause conflict my code. So I will modify my commit and apply dev branch again. |
I changed base branch from 'master' to 'dev'. please review again. |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
Hi, Sorry for the delay. I reviewed, and took your branch and applied a few changes:
Here is a branch: One remaining thing to do is parsing flags. For example, on my device, here is an extract of
The declared flags must be set in the |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
3e6001d
to
acacf61
Compare
Great work. |
Thanks, I will try to review soon.
Even without multi-line, this avoids the regex engine to try to match the regex everywhere in the line (it forces to only match at the beginning of the line, so in theory the perfs are better). |
I added Pattern.MULTILINE option. It works. |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
Thank you. About the flags capture, since the captured text might include non-flags (fields not beginning with I also extracted to a separate function to call the parsing function from unit tests, and I added a unit test: |
cf67cce
to
d97ce7b
Compare
Thank you. There is more something to check after Android API 31. In API31 emulator
So, I added test case for API 31, And I change regex from |
And I added testcase for No FLAG display. |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
👍 I rebased on
diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
index 9967c74e..4a2a65be 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
@@ -21,8 +21,8 @@ public final class DisplayManager {
// public to call it from unit tests
public static DisplayInfo parseDisplayInfo(String dumpsysDisplayOutput, int displayId) {
Pattern regex = Pattern.compile(
- "^ mBaseDisplayInfo=DisplayInfo\\{\".*\", displayId " + displayId + ".*?(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*, rotation ([0-9]+)"
- + ".*, layerStack ([0-9]+)",
+ "^ mBaseDisplayInfo=DisplayInfo\\{\".*\", displayId " + displayId + ".*(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*, rotation " +
+ "([0-9]+).*, layerStack ([0-9]+)",
Pattern.MULTILINE);
Matcher m = regex.matcher(dumpsysDisplayOutput);
if (!m.find()) {
@@ -49,17 +49,19 @@ public final class DisplayManager {
private static int parseDisplayFlags(String text) {
Pattern regex = Pattern.compile("FLAG_[A-Z_]+");
+ if (text == null) {
+ return 0;
+ }
+
int flags = 0;
- if (text != null) {
- Matcher m = regex.matcher(text);
- while (m.find()) {
- String flagString = m.group();
- try {
- Field filed = Display.class.getDeclaredField(flagString);
- flags |= filed.getInt(null);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- // Silently ignore, some flags reported by "dumpsys display" are @TestApi
- }
+ Matcher m = regex.matcher(text);
+ while (m.find()) {
+ String flagString = m.group();
+ try {
+ Field filed = Display.class.getDeclaredField(flagString);
+ flags |= filed.getInt(null);
+ } catch (NoSuchFieldException | IllegalAccessException e) {
+ // Silently ignore, some flags reported by "dumpsys display" are @TestApi
}
}
return flags;
diff --git a/server/src/test/java/com/genymobile/scrcpy/CommandParserTest.java b/server/src/test/java/com/genymobile/scrcpy/CommandParserTest.java
index 460835dd..33810265 100644
--- a/server/src/test/java/com/genymobile/scrcpy/CommandParserTest.java
+++ b/server/src/test/java/com/genymobile/scrcpy/CommandParserTest.java
@@ -9,7 +9,7 @@ import org.junit.Test;
public class CommandParserTest {
@Test
- public void testParseDisplayInfoFrqomDumpsysDisplay() {
+ public void testParseDisplayInfoFromDumpsysDisplay() {
/* @formatter:off */
String partialOutput = "Logical Displays: size=1\n"
+ " Display 0:\n"
@@ -51,7 +51,7 @@ public class CommandParserTest {
}
@Test
- public void testParseDisplayInfoFrqomDumpsysDisplayAPI31() {
+ public void testParseDisplayInfoFromDumpsysDisplayAPI31() {
/* @formatter:off */
String partialOutput = "Logical Displays: size=1\n"
+ " Display 0:\n"
@@ -97,7 +97,7 @@ public class CommandParserTest {
}
@Test
- public void testParseDisplayInfoFrqomDumpsysDisplayAPI31NoFlags() {
+ public void testParseDisplayInfoFromDumpsysDisplayAPI31NoFlags() {
/* @formatter:off */
String partialOutput = "Logical Displays: size=1\n"
+ " Display 0:\n"
@@ -136,7 +136,6 @@ public class CommandParserTest {
Assert.assertEquals(0, displayInfo.getDisplayId());
Assert.assertEquals(0, displayInfo.getRotation());
Assert.assertEquals(0, displayInfo.getLayerStack());
- // FLAG_TRUSTED does not exist in Display (@TestApi), so it won't be reported
Assert.assertEquals(0, displayInfo.getFlags());
Assert.assertEquals(1080, displayInfo.getSize().getWidth());
Assert.assertEquals(2280, displayInfo.getSize().getHeight()); |
It's almost done. |
Hmm, indeed, but I don't understand why:
Why is |
@rom1v |
I tested regex in https://regex101.com/r/8tpLez/1 |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
I pushed However, I noticed a problem when the initial rotation is not the natural orientation (for example by running Firefox while the phone is in landscape mode), the reported rotation is not correct (so mirroring is broken). The problem is that there are both
I guess that the correct width and height must be read from the |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
Ah no, everything must be read from diff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
index 19568489..bf172126 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/DisplayManager.java
@@ -21,8 +21,8 @@ public final class DisplayManager {
// public to call it from unit tests
public static DisplayInfo parseDisplayInfo(String dumpsysDisplayOutput, int displayId) {
Pattern regex = Pattern.compile(
- "^ mBaseDisplayInfo=DisplayInfo\\{\".*?\", displayId " + displayId + ".*?(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*?, rotation "
- + "([0-9]+).*?, layerStack ([0-9]+)",
+ "^ mOverrideDisplayInfo=DisplayInfo\\{\".*?\", displayId " + displayId + ".*?(, FLAG_.*)?, real ([0-9]+) x ([0-9]+).*?, "
+ + "rotation ([0-9]+).*?, layerStack ([0-9]+)",
Pattern.MULTILINE);
Matcher m = regex.matcher(dumpsysDisplayOutput);
if (!m.find()) { Branch (And I added a unit test to check the rotation value and the correct width and height when rotated.) |
PR #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
You caught the bug well. :) I agree to change from "mBaseDisplayInfo" to "mOverrideDisplayInfo". thank you! |
Merged into |
The DisplayInfo dump format has slightly changed in AOSP: <https://android.googlesource.com/platform/frameworks/base.git/+/1039ea50f3e1944f5d670cfdeadfdb17b3442ed7> PR #3573 <#3573> Ref #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
The DisplayInfo dump format has slightly changed in AOSP: <https://android.googlesource.com/platform/frameworks/base.git/+/1039ea50f3e1944f5d670cfdeadfdb17b3442ed7> PR #3573 <#3573> Ref #3416 <#3416> Signed-off-by: Romain Vimont <[email protected]>
Sometimes, VirtualDisplay DisplayInfo object returns null, So, I fix getting displayInfo from "dumpsys display".